from config import HOST


class ApiApproveTrust:
    # 初始化
    def __init__(self, session):
        self.session = session

        self.__url_approve = HOST + '/member/realname/approverealname'
        self.__url_approve_status = HOST + '/member/member/getapprove'
        self.__url_trust = HOST + '/trust/trust/register'
        self.__url_img_code = HOST + '/common/public/verifycode/{}'
        self.__url_recharge = HOST + '/trust/trust/recharge'

    # 认证接口
    def api_approve(self, card_id='140107201201156329'):
        # 1.请求参数
        data = {'realname': '张三',
                'card_id': '140107201201156329'}
        # 2.请求方法,难点请求数据使multipart/form-data,使用data+files解决
        return self.session.post(url=self.__url_approve, data=data, files={'x': 'y'})

    # 获取认证信息接口
    def api_approve_status(self):
        return self.session.post(url=self.__url_approve_status)

    # 开户接口
    def api_trust(self):
        return self.session.post(url=self.__url_trust)

    # 获取充值验证码接口
    def api_img_code(self, random):
        return self.session.get(url=self.__url_img_code.format(random))

    # 充值接口
    def api_recharge(self, valicode):
        data = {
            'paymentType': 'chinapnrTrust',
            'amount': 10000,
            'formStr': 'reForm',
            'valicode': valicode
        }
        return self.session.post(url=self.__url_recharge, data=data)
